package com.lishe.lishe.lishe.module.mall.adapter;

import android.support.v7.widget.RecyclerView;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.lishe.lishe.R;
import com.lishe.lishe.lishe.MyRecyclerView.RecyclerviewBaseAdapter;
import com.lishe.lishe.lishe.module.mall.bean.MallGoods;

/**
 * Created by Bin
 * 促销信息弹窗 adapter
 */

public class GoodsPromotionAdapter extends RecyclerviewBaseAdapter {

    private SparseArray<MallGoods.Discount> mPromotionList;

    public GoodsPromotionAdapter(SparseArray<MallGoods.Discount> list) {
        this.mPromotionList = list;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolderMy(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_goodspromotion, null);
        ViewHolder holder = new ViewHolder(view);
        return holder;
    }

    @Override
    public void onBindViewHolderMy(RecyclerView.ViewHolder holder0, int position) {
        ViewHolder holder = (ViewHolder) holder0;
        holder.text.setText(mPromotionList.get(position).getTitle());
    }

    @Override
    public int getItemCountMy() {
        return mPromotionList == null ? 0 : mPromotionList.size();
    }

    @Override
    public int getItemViewTypeMy(int position) {
        return 0;
    }

    class ViewHolder extends RecyclerView.ViewHolder {

        TextView text;

        public ViewHolder(View itemView) {
            super(itemView);
            text = itemView.findViewById(R.id.text);
        }
    }
}
